package com.hznu.ez4life.modules.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.hznu.ez4life.modules.entity.Assess;
import com.hznu.ez4life.modules.dao.AssessDao;
import com.hznu.ez4life.modules.service.AssessService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hznu.ez4life.modules.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author DragonDoor
 * @since 2019-07-25
 */
@Service
public class AssessServiceImpl extends ServiceImpl<AssessDao, Assess> implements AssessService {

    @Autowired
    UserService userService;

    @Override
    public List<Assess> findListByevaId(Integer evaId)
    {
        List<Assess> assesses = this.selectList(new EntityWrapper<Assess>().eq("eva_id",evaId));
        for (Assess assess:assesses)
        {
            if(assess.getUserId()!=null)
            {
                assess.setUser(userService.findById(assess.getUserId()));
            }

        }
        return assesses;
    }

    @Override
    public void addOne(Assess assess)
    {
        assess.setAsstime(new Date(System.currentTimeMillis()));
        this.insert(assess);
    }

    private void setDetail(Assess assess)
    {

    }

}
